﻿using System.Text.RegularExpressions;
using ValueOf;

namespace Customers.Api.Domain.Common;

public class FullName : ValueOf<string, FullName>
{
    private static readonly Regex FullNameRegex = new("^[a-z ,.'-]+$", RegexOptions.Compiled | RegexOptions.IgnoreCase);

    protected override void Validate()
    {
        if (!FullNameRegex.IsMatch(Value))
        {
            this.ThrowValidationException(nameof(FullName), $"{Value} is not a valid full name");
        }
    }
}